package com.yingjia.yingjiauniversity.utils;

import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.os.Bundle;

import com.my.common.constant.Contexts;

import org.slf4j.LoggerFactory;

public class SendBroadcast {
    public static void TimeSendBroadcastReceiver(Context context, int hour, int minutes) {
        if (context == null)
            return;
        Intent intent = new Intent();
        intent.setAction(Contexts.TIMEBROADCAST);
        Bundle bundle = new Bundle();
        bundle.putInt("hour", hour);
        bundle.putInt("minutes", minutes);
        intent.putExtras(bundle);
        context.sendBroadcast(intent);
        bundle = null;
        intent = null;
    }

    public static void BatteryBroadcastReceiver(Context context, int level, int scale, int status) {
        if (context == null)
            return;
        Intent intent = new Intent();
        intent.setAction(Contexts.BATTERYRECEIVER);
        Bundle bundle = new Bundle();
        bundle.putInt("level", level);
        bundle.putInt("scale", scale);
        bundle.putInt("status", status);
        intent.putExtras(bundle);
        context.sendBroadcast(intent);
        bundle = null;
        intent = null;

    }

    public static void SIMBroadcastReceiver(Context context, int len) {
        if (context == null)
            return;
        Intent intent = new Intent();
        intent.setAction(Contexts.SIMBROADCASTRECEIVER);
        Bundle bundle = new Bundle();
        bundle.putInt("status", len);
        intent.putExtras(bundle);
        context.sendBroadcast(intent);
        bundle = null;
        intent = null;
    }

    public static void WIFIBroadcastReceiver(Context context, int level, boolean status) {
        if (context == null)
            return;
        Intent intent = new Intent();
        intent.setAction(Contexts.WIFIBROADCASTRECEIVER);
        Bundle bundle = new Bundle();
        bundle.putInt("wifilevel", level);
        bundle.putBoolean("status", status);
        intent.putExtras(bundle);
        context.sendBroadcast(intent);
        bundle = null;
        intent = null;
    }

    public static void GPSBroadcastReceiver(Context context, Location location, int count) {
        if (context == null)
            return;
        Intent intent = new Intent();
        intent.setAction(Contexts.GPSBROADCASTRECEIVER);
        Bundle bundle = new Bundle();
        if (location != null) {
            bundle.putDouble("Longitude", location.getLongitude());
            bundle.putDouble("Altitude", location.getAltitude());
            bundle.putDouble("Latitude", location.getLatitude());
            bundle.putFloat("Speed", location.getSpeed());
            bundle.putFloat("Bearing", location.getBearing());
            bundle.putFloat("Accuracy", location.getAccuracy());
            bundle.putLong("time", location.getTime());
            bundle.putInt("count", count);
            bundle.putInt("location", 1);
        } else {
            bundle.putDouble("Longitude", 0);
            bundle.putDouble("Altitude", 0);
            bundle.putDouble("Latitude", 0);
            bundle.putFloat("Speed", 0);
            bundle.putFloat("Bearing", 0);
            bundle.putFloat("Accuracy", 0);
            bundle.putLong("time", 0);
            bundle.putInt("count", count);
            bundle.putInt("location", 0);
        }
        intent.putExtras(bundle);
        context.sendBroadcast(intent);
        bundle = null;
        intent = null;
    }

    public static void GPSBroadcastReceiver2(Context context, boolean bSwitchOn) {
        if (context == null)
            return;
        Intent intent = new Intent();
        intent.setAction(Contexts.GPSBROADCASTRECEIVER2);

        Bundle bundle = new Bundle();
        bundle.putBoolean("switch_opt", bSwitchOn);
        intent.putExtras(bundle);

        context.sendBroadcast(intent);
        bundle = null;
        intent = null;
    }

    public static void BackBroadcastReceiver(Context context) {
        if (context == null)
            return;
        Intent intent = new Intent();
        intent.setAction(Contexts.BACKBAROADCASTRECEIVER);
        context.sendBroadcast(intent);
        intent = null;
    }

    public static void ExceptionBroadcastReceiver(Context context, int count) {
        Intent intent = new Intent();
        intent.setAction(Contexts.EXCEPTIONBROADCASTRECEIVER);
        Bundle bundle = new Bundle();
        bundle.putInt("len", count);
        intent.putExtras(bundle);
        context.sendBroadcast(intent);
        bundle = null;
        intent = null;
    }

    public static void GPSReportingBroadcastReceiver(Context context, int len) {
        if (context == null)
            return;
        Intent intent = new Intent();
        intent.setAction(Contexts.GPSREPORTINGRECEIVER);
        Bundle bundle = new Bundle();
        bundle.putInt("gpsType", len);
        intent.putExtras(bundle);
        context.sendBroadcast(intent);
        bundle = null;
        intent = null;
    }

    public static void MsgitemBroadcastReceiver(Context context) {
        if (context == null)
            return;
        Intent intent = new Intent();
        intent.setAction(Contexts.MESSAGE_HANDLER_BROADCAST);
        context.sendBroadcast(intent);
        intent = null;
    }

    public static void BluetoothReceiver(Context context, int len) {
        if (context == null) {
            return;
        }
        Intent intent = new Intent();
        intent.setAction(Contexts.BLUETOOTNBROADCASTRECEIVER);
        Bundle bundle = new Bundle();
        bundle.putInt("count", len);
        intent.putExtras(bundle);
        context.sendBroadcast(intent);
        bundle = null;
        intent = null;
    }

    public static void OpenTrafficBroadcast(Context context) {
        if (context == null) {
            return;
        }
        Intent intent = new Intent();
        intent.setAction(Contexts.OPENTRAFFICBROADCAST);
        context.sendBroadcast(intent);
        intent = null;
    }

    public static void sendFullCreenBroadcast(Context context) {
        if (context == null) {
            return;
        }
        Intent intent = new Intent();
        intent.setAction(Contexts.FULLCREENBROADCAST);
        context.sendBroadcast(intent);
        intent = null;

    }

    public static void sendPlaybackProgress(Context context, long prog) {
        if (context == null) {
            return;
        }
        Intent intent = new Intent();
        intent.setAction(Contexts.PLAYBACKPROGRESS);
        intent.putExtra("playcallback", prog);
        context.sendBroadcast(intent);
        intent = null;
    }

    /**
     * 前后置摄像头横竖屏切换的广播
     */
    public static void sendOrientionScreen(Context context, int len) {
        if (context == null) {
            LoggerFactory.getLogger(SendBroadcast.class).info("close_soloview == {}", "broadcast sendOrientionScreen  == ");
            return;
        }
        Intent intent = new Intent();
        intent.setAction(Contexts.ORIENTATIONCAMEARReceiver);
        intent.putExtra("orientation", len);
        context.sendBroadcast(intent);
        intent = null;
        LoggerFactory.getLogger(SendBroadcast.class).info("close_soloview == {}", "broadcast sendOrientionScreen  == ");
    }

    /**
     * 时间显示
     */
    public static void sendOpenCloseTime(Context context, int len) {
        if (context == null) {
            return;
        }
        Intent intent = new Intent();
        intent.setAction(Contexts.OPENCLOSETIMErECEIVE);
        intent.putExtra("openAudio", len);
        context.sendBroadcast(intent);
        intent = null;
    }
}
